package com.cluster.platform.controller;

import com.cluster.platform.common.api.CommonResult;
import com.cluster.platform.dto.SysDictInfoDto;
import com.cluster.platform.model.SysDictInfo;
import com.cluster.platform.service.SysDictInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 系统字典
 *
 * @ClassName: SysDictController
 */
@Controller
@Api(tags = "系统字典接口", value = "SysDictController")
@RequestMapping("/sysDict")
public class SysDictController {

    @Autowired
    SysDictInfoService sysDictInfoService;

    @ApiOperation("批量操作")
    @RequestMapping(value = "/updateBatchDict", method = RequestMethod.PUT)
    @ResponseBody
    public CommonResult<Object> updateBatchDict(@RequestParam("status") String status, @RequestParam("ids") List<String> ids) {
        return sysDictInfoService.updateBatchDict(status,ids);
    }

    @ApiOperation("获取系统字典信息")
    @RequestMapping(value = "/searchSysDict", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Object> searchSysDict(@RequestBody SysDictInfo sysDictInfo) {
        return sysDictInfoService.searchSysDictInfo(sysDictInfo);
    }

    @ApiOperation("获取系统字典信息--分页")
    @RequestMapping(value = "/searchSysDictPage", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Object> searchSysDict(@RequestBody SysDictInfoDto sysDictInfoDto) {
        return sysDictInfoService.fetchList(sysDictInfoDto);
    }

    @ApiOperation("新增系统字典信息")
    @RequestMapping(value = "/addSysDict", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<Object> addSysDict(@RequestBody SysDictInfo sysDictInfo) {
        return sysDictInfoService.addSysDictInfo(sysDictInfo);
    }

    @ApiOperation("修改系统字典信息")
    @RequestMapping(value = "/updateSysDict", method = RequestMethod.PUT)
    @ResponseBody
    public CommonResult<Object> updateSysDict(@RequestBody SysDictInfo sysDictInfo) {
        return sysDictInfoService.updateSysDictInfo(sysDictInfo);
    }

    @ApiOperation("删除系统字典信息")
    @RequestMapping(value = "/delSysDict", method = RequestMethod.DELETE)
    @ResponseBody
    public CommonResult<Object> delSysDict(@RequestBody SysDictInfo sysDictInfo) {
        return sysDictInfoService.delSysDictInfo(sysDictInfo);
    }
}
